package com.hj.saapp.common.manager;


import android.text.TextUtils;

import com.hj.saapp.BCDApplication;
import com.hj.saapp.bean.LoginBean;

import com.hj.saapp.common.utils.PreferencesUtils;

import lib.hj.com.commonlib.utils.Constant;

/**
 * YZ
 * 管理用户相关的信息
 * Created by Administrator on 2015/10/14.
 */
public class UserManager {

    private static UserManager manager;

    private  boolean isLogin = false;

    private String yhm ="";
    private String dwmc ="";
    private String dwdm ="";
    private String js = "";
    private String userid ="";

    public String getUserid() {
        String username = PreferencesUtils.getInstance().getString(Constant.username);
        if (!TextUtils.isEmpty(username)) {
            userid = username;
        }

        return userid;
    }

    public void setUserid(String userid) {
        this.userid = userid;
    }

    public String getJs() {
        return js;
    }

    public void setJs(String js) {
        this.js = js;
        PreferencesUtils.getInstance().putString(BCDApplication.getApp(), Constant.js, js);

    }




    public boolean isLogin() {
        return isLogin;
    }

    public void setLogin(boolean login) {
        isLogin = login;
    }

    public String getYhm() {
        return yhm;
    }

    public void setYhm(String yhm) {
        this.yhm = yhm;
        PreferencesUtils.getInstance().putString(BCDApplication.getApp(), Constant.yhm, yhm);
    }

    public String getDwmc() {
        return dwmc;
    }

    public void setDwmc(String dwmc) {
        PreferencesUtils.getInstance().putString(BCDApplication.getApp(), Constant.dwmc, dwmc);
        this.dwmc = dwmc;
    }

    public String getDwdm() {
        return dwdm;
    }

    public void setDwdm(String dwdm) {
        PreferencesUtils.getInstance().putString(BCDApplication.getApp(), Constant.dwdm, dwdm);

        this.dwdm = dwdm;
    }

    public static UserManager getUserManager()
    {
        if (manager == null)
        {
            manager = new UserManager();
        }
        return manager;
    }

    /**
     * 设置登陆状态
     */
    public void setLoginStatus(boolean isLogin)
    {
        this.isLogin = isLogin;
    }


    /**
     * 设置用户信息
     */
    public void setUserInfo(LoginBean cb)
    {

        setLoginStatus(true);
        setYhm(cb.getYhm());
        setDwdm(cb.getDwdm());
        setDwmc(cb.getDwmc());
        setJs(cb.getJs());

    }

    /**
     * 清除用户信息
     */
    public void clearUserInfo()
    {
        setLoginStatus(false);
    }

    /**
     * 设置登陆状态
     */
    public boolean getLoginStatus()
    {
        return  isLogin;
    }



}
